"""
角色模型定义
实现RBAC权限控制的角色部分
"""
from tortoise import fields

from pkg.common.models.base_model import BaseModel


class Role(BaseModel):
    """角色模型"""
    
    name = fields.CharField(max_length=50, description="角色名称")
    slug = fields.CharField(max_length=50, unique=True, description="角色标识")
    description = fields.TextField(null=True, description="角色描述")
    is_system = fields.BooleanField(default=False, description="是否为系统角色")
    
    # 多对多关系将在relations.py中实现
    
    class Meta:
        table = "roles"
        table_description = "角色表"
        app = "models"
    
    def __str__(self):
        return f"Role(id={self.id}, name={self.name})"
